/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package GUI;

import Busquedas.Estado;
import java.awt.Color;
import java.awt.Graphics;
import java.util.ArrayList;
import javax.swing.JComponent;

/**
 *
 * @author Jaime
 */
public class DibujaSolucion extends JComponent{
private static final long serialVersionUID = 1L;

    private ArrayList<Estado> solucion;
    private ArrayList<String> sol;


    public DibujaSolucion(ArrayList<Estado> e,ArrayList<String> s){
        //this.numPlaneta=nP;
        solucion=e;
        sol=s;

    }
    public void paintComponent(Graphics g)
    {
        super.paintComponent(g);
        //setG(g);
        dibujaPSolucion(g);
    }

    public void dibujaPSolucion(Graphics g) {
        
        Estado aux;

        for (int i=0;i<solucion.size()-1;i++){
            String s=sol.get(i);
            if (i==0){g.setColor(Color.RED);}
            else{
                if(s.equals("derecha")){g.setColor(Color.BLUE);}
                if(s.equals("izquierda")){g.setColor(Color.GREEN);}
                if(s.equals("arriba")){g.setColor(Color.YELLOW);}
                if(s.equals("abajo")){g.setColor(Color.PINK);}
            }
            aux=solucion.get(i);
            int numPlaneta= planetaCoor(aux.getParametro(0),aux.getParametro(1));
            Punto posicion=this.NumPlanetaToPunto(numPlaneta);
            g.fillOval(posicion.getX(),posicion.getY(), 20, 20);
            
        }
       
    }

    private Punto NumPlanetaToPunto(int nP)
    {
       int x=0;
       int y=0;
       int columna=nP % 19;
       switch (columna)
       {
           case 1: x=40;
                break;
           case 2: x=80;
                break;
           case 3: x=120;
                break;
           case 4: x=160;
                break;
           case 5: x=200;
                break;
           case 6: x=240;
                break;
           case 7: x=280;
                break;
           case 8: x=320;
                break;
           case 9: x=360;
                break;
           case 10: x=400;
                break;
           case 11: x=440;
                break;
           case 12: x=480;
                break;
           case 13: x=520;
                break;
           case 14: x=560;
                break;
           case 15: x=600;
                break;
           case 16: x=640;
                break;
           case 17: x=680;
                break;
           case 18: x=720;
                break;
           case 0: x=760;
                break;
       }

       if(nP>=1 && nP<=19)
          y=10;
       else if(nP>=20 && nP<=38)
               y=50;
            else if(nP>=39 && nP<=57)
                    y=90;
                else if(nP>=58 && nP<=76)
                        y=130;
                    else if(nP>=77 && nP<=95)
                             y=170;
                        else if(nP>=96 && nP<=114)
                                y=210;
                            else if(nP>=115 && nP<=133)
                                    y=250;
                                else if(nP>=134 && nP<=152)
                                        y=290;
                                    else if(nP>=153 && nP<=171)
                                            y=330;
                                        else if(nP>=172 && nP<=190)
                                                y=370;
                                            else if(nP>=191 && nP<=209)
                                                    y=410;
                                                else if(nP>=210 && nP<=228)
                                                        y=450;
                                                     else if(nP>=229 && nP<=247)
                                                              y=490;

       return new Punto(x,y);

    }
  public int planetaCoor(int k,int x){
 //      int y=(i*19+j);
    return (k*19+x+1);
}


}
